<template>
  <div class="app-container">
    <el-row :gutter="20">
      <!--el-row, rl-col layout布局组件
      el-row gutter 属性来指定每一栏之间的间隔
      rl-col span	栅格占据的列数
              xs	<768px 响应式栅格数或者栅格属性对象
      -->
      <!-- 部门数据 -->
      <el-col :span="4" :xs="24">
        <div class="head-container">
          <!--
            el-input input输入框组件
            clearable 得到一个属性即可得到一个可清空的输入框-->
          <el-input v-model="deptName" placeholder="请输入部门" clearable size="small" prefix-icon="el-icon-search"
            style="margin-bottom: 20px" />
        </div>
        <div class="head-container">
          <!--el-tree Tree 树形控件
          是否高亮当前选中节点，默认值是 false
          default-expand-all	是否默认展开所有节点  默认false
          expand-on-click-node	是否在点击节点的时候展开或者收缩节点， 默认值为 true，如果为 false，则只有点箭头图标的时候才会展开或者收缩节点 默认true
          :data v-bind:data="deptList"  v-bind语法
           -->
          <el-tree :data="depts" :props="defaultProps" :expand-on-click-node="false" :filter-node-method="filterNode"
            ref="tree" default-expand-all highlight-current @node-click="handleNodeClick" />
        </div>
      </el-col>

      <!--用户数据 -->
      <el-col :span="20" :xs="24">
        <!-- 
          elementUI Form 表单 组件
          :model 表单数据对象
        -->
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
          label-width="68px">

          <!--prop="userName" 这个是el-form-item的接收字段，里面的v-model="queryParams.userName" 双向绑定，最后用的是el-form-item的prop -->
          <el-form-item label="用户名称" prop="userName">
            <!--v-model 非常重要，vue提供了v-model双向数据绑定指令，用来辅助开发者在不操作DOM的前提下，快速获取表单的数据 -->
            <el-input v-model="queryParams.userName" placeholder="请输入用户名称" clearable style="width: 240px"
              @keyup.enter.native="handlerQuery" />
          </el-form-item>

          <!-- 
            prop的作用?
            1.一开始是 el-form-item label="手机号码"prop="phonenumber" ，删了prop可以查询。
            百度： 使用表格组件的时候，显示数据，可以用 prop="phonenumber" 显示，查询用的v-model双向绑定数据，下面的表格el-table的里的el-table-column type="用户编号" align="center" key="userId" prop="userId",这里的prop有用
            2.prop配合ref使用，下面this.resetForm("queryForm")有prop的置空，没有prop的没有置空 prop="phonenumber"
             -->
          <el-form-item label="手机号码" prop="phonenumber">
            <el-input v-model="queryParams.phonenumber" placeholder="请输入手机号码" clearable style="width: 240px"
              @keyup.enter.native="handlerQuery" />
          </el-form-item>

          <el-form-item label="状态" prop="status">
            <el-select v-model="queryParams.status" placeholder="用户状态" clearable style="width: 240px">
              <el-option v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.label"
                :value="dict.value"></el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="用户角色" prop="roleId">
            <el-select v-model="queryParams.roleId" placeholder="用户角色" clearable style="width: 240px">
              <!-- :key给dom标签用， :value选择的值， :label标签显示值 -->
              <el-option v-for="role in roles" :key="role.roleId" :value="role.roleId"
                :label="role.roleName"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="创建时间">
            <el-date-picker v-model="dateRange" style="width: 240px" value-format="yyyy-MM-dd" type="daterange"
              range-separator="-" start-placeholde="开始日期" end-placeholde="结束日期" />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <!--存在权限字符串才能看到
            plain 是否朴素按钮 
            type	类型	string	primary / success / warning / danger / info / text
            -->
            <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handlerAdd"
              v-hasPermi="['system:user:add']">新增</el-button>
          </el-col>
          <el-col :span="1.5">
            <!-- 下面的handlerUpdate有row变量传进去，这里这个没，然后这个点击这个修改代码报错了，第一个显示变量nickName就没有，为啥有错？ -->
            <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
              v-hasPermi="['system.user:edit']">修改</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handlerDelete"
              v-hasPermi="['system.user:remove']">删除</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="info" plain icon="el-icon-update2" size="mini" @click="handleImport"
              v-hasPermi="['system.user.import']">导入</el-button>
          </el-col>

          <el-col :span="1.5">
            <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
              v-hasPermi="['system.user:export']">导出</el-button>
          </el-col>

          <!--right-toolbar 全局挂载组件，/compoents/RightToolbar
          搜索，刷新，显示 按钮 
          父组件向子组件传值 :showSearch.sync  :columns
          -->
          <right-toolbar :showSearch.sync="showSearch" @queryTrable="getList" :columns="columns"></right-toolbar>
        </el-row>

        <el-table v-loading="loading" :data="users" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column type="用户编号" align="center" key="userId" prop="userId" v-if="columns[0].visible" />
          <el-table-column label="用户名称" align="center" key="userName" prop="userName" v-if="columns[1].visible"
            :show-overflow-tooltip="true" />
          <el-table-column label="用户昵称" align="center" key="nickName" prop="nickName" v-if="columns[2].visible"
            :show-overflow-tooltip="true" />
          <el-table-column label="部门" align="center" key="deptName" prop="dept.deptName" v-if="columns[3].visible"
            :show-overflow-tooltip="true" />
          <el-table-column label="手机号码" align="center" key="phonenumber" prop="phonenumber" v-if="columns[4].visible"
            width="120" />
          <el-table-column label="状态" align="center" key="status" v-if="columns[5].visible">
            <template slot-scope="scope">
              <el-switch v-model="scope.row.status" active-value="0" inactive-value="1"
                @change="handlerStatusChange(scope.row)"></el-switch>
            </template>
          </el-table-column>
          <el-table-column label="创建时间" align="center" prop="createTime" v-if="columns[6].visible" width="160">
            <!--slot-scope 父组件传递一个对象给子组件
            写法1：slot-scope="scope"
            写法2：slot-scope="{ row }" 也可以用解构的方式
            parseTime main.js全局方法挂载
             -->
            <template slot-scope="{row}">
              <span>{{ parseTime(row.createTime) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width">
            <!-- 聪明啊，不用写表头，一个v-if就可以按钮就出来了，之前写jsp还单独写表头、表body -->
            <template slot-scope="{row}" v-if="row.userId !==1">
              <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(row)"
                v-hasPermi="['system:user:edit']">修改</el-button>
              <el-button size="mini" type="text" icon="el-icon-delete" @click="handlerDelete(row)"
                v-hasPermi="['system:user:remove']">删除</el-button>
              <!-- el-dropdown 下拉菜单 -->
              <el-dropdown szie="mini" @command="(command) => handleCommand(command,row)"
                v-hasPermi="['system:user:resetPwd','system:user:edit']">
                <span class="el-dropdown-link"><i class="el-icon-d-arrow-right"></i>更多</span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item command="handleResetPwd" icon="el-icon-key"
                    v-hasPermi="['system:user:resetPwd']">重置密码</el-dropdown-item>
                  <el-dropdown-item command="handleAuthRole" icon="el-icon-circle-check"
                    v-hasPermi="['system:user:edit']">分配角色</el-dropdown-item>

                  <el-dropdown-item command="handleAuthDept" icon="el-icon-circle-check"
                    v-hasPermi="['system:user:edit']">分配部门</el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </template>
          </el-table-column>
        </el-table>

        <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
          @pagination="getList" />
      </el-col>

    </el-row>

    <!-- 添加或修改用户配置对话框
    title,open需要定义 父向子传值用：,所以父组件:tile="title", :visble.sync="open" 里面的属性需要定义
     -->
    <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
      <!--rules 属性传入约定的验证规则，并将 Form-Item 的 prop 属性设置为需校验的字段名即可 -->
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="12">
            <!-- v-model="form.nickname" 双向绑定值-->
            <el-form-item label="用户昵称" prop="nickName">
              <el-input v-model="form.nickName" placeholder="请输入用户昵称" maxlength="30" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="归属部门" prop="deptId">
              <treeselect v-model="form.deptId" :options="depts" :show-count="true" placeholder="请选择归属部门">
              </treeselect>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="手机号码" prop="phonenumber">
              <el-input v-model="form.phonenumber" placeholder="请输入手机号" maxlength="11" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="邮箱" prop="email">
              <el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="用户名" v-if="form.userId == undefined" prop="userName">
              <el-input v-model="form.userName" maxlength="30" placeholder="请输入用户名称" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <!--如果用户不存在显示密码输入 -->
            <el-form-item label="密码" v-if="form.userId == undefined" prop="password">
              <el-input v-model="form.password" maxlength="20" placeholder="请输入密码" type="password" show-password />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="用户性别">
              <el-select v-model="form.sex" placeholder="请选择性别">
                <!--
                  key的作用？
                  key的作用就是更新组件时判断两个节点是否相同。相同就复用，不相同就删除旧的创建新的。
                key的作用主要是为了高效的更新虚拟DOM.用index做删除会产生不必要的bug
                https://www.jianshu.com/p/bf82e99fa0a1

                dict 怎么来的？
                todo main加载的公共 Dict.js ,原理得弄懂
                参考： https://blog.csdn.net/u013034585/article/details/122185684 
                https://www.zhihu.com/tardis/zm/art/618540640?source_id=1005
                 -->
                <el-option v-for="dict in dict.type.sys_user_sex" :key="dict.value" :label="dict.label"
                  :value="dict.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="状态">
              <el-radio-group v-model="form.status">
                <el-radio v-for="dict in dict.type.sys_normal_disable" :key="dict.value"
                  :label="dict.value">{{dict.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="岗位">
              <el-select v-model="form.postIds" multiple placeholder="请选择岗位">
                <el-option v-for="item in posts" :key="item.postId" :label="item.postName" :value="item.postId"
                  :disabled="item.status ==1"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="角色">
              <!-- 这里需要注意，如果加了multiple ，roleIds就是一个数据，如果不加，传给接口的时候变成了单个属性，不是数组了 -->
              <el-select v-model="form.roleIds" multiple placeholder="请选择角色">
                <el-option v-for="item in roles" :key="item.roleId" :value="item.roleId" :label="item.roleName"
                  :disabled="item.status ==1"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="备注">
              <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" maxlength="2000" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确定</el-button>
        <el-button @click="cancel">取消</el-button>
      </div>

    </el-dialog>

    <!-- 用户导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload ref="upload" :limit="1" accept=".xlsx,.xls" :headers="upload.headers"
        :action="upload.url+'?updateSupport'+upload.updateSupport" :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的记录
          </div>
          <span>仅允许导入xls,xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;"
            @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确定</el-button>
        <el-button @click="upload.open =false">取消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { getUsers, getRoles, deptTreeSelect, changeUserStatus, getPosts, updateUser, addUser, getUserById, deleteUser, resetUserPwd } from '@/api/wu/myUser';
//@ 代表 src目录
import { getToken } from "@/utils/auth";
//@riophae/vue-treeselect node_modules里面的@riophae
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";


export default {
  name: "myuser",
  dicts: ['sys_normal_disable', 'sys_user_sex'],
  components: {
    Treeselect,
  },
  data() {
    return {
      // 遮罩层,用户数据没出来前有一层模糊的遮罩
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户表格数据
      users: null,
      depts: null,
      form: {},
      // 弹出层标题
      title: "",
      open: null,
      deptOptions: null,
      // 部门名称
      deptName: undefined,
      roles: [],
      users: [],
      dateRange: [],
      initPassword: '123456',
      posts: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName: undefined,
        phonenumber: undefined,
        status: undefined,
        deptId: undefined,
        roleId: undefined,
        email: undefined,
        sex: undefined,
        status: undefined,
        remark: undefined,
        roleIds: [],
        postIds: []
      },
      defaultProps: {
        children: "children",
        label: "label"
      },
      // 列信息，这个columns 的作用就是如果不想显示那个列，改visible属性就行，公共组件right-toolbar
      columns: [
        { key: 0, label: `用户编号`, visible: true },
        { key: 1, label: `用户名称`, visible: true },
        { key: 2, label: `用户昵称`, visible: true },
        { key: 3, label: `部门`, visible: true },
        { key: 4, label: `手机号码`, visible: true },
        { key: 5, label: `状态`, visible: true },
        { key: 6, label: `创建时间`, visible: true }
      ],
      /*表单校验
      trigger blur表示失去焦点时才触发验证，change表示值改变时就触发。
      加 required: true 前面有小红点
      */
      rules: {
        userName: [
          { required: true, message: "用户名不能为空", trigger: "blur" },
          { min: 2, max: 20, message: '用户名长度必须介于 2 和 20 之间', trigger: 'blur' }
        ],
        nickName: [
          { required: true, message: "昵称不能为空", trigger: "blur" }
        ],
        password: [
          { required: true, message: "密码不能为空", trigger: "blur" },
          { min: 5, max: 20, message: '密码长度必须介于 5 和 20 之间', trigger: 'blur' }
        ],
        email: [
          {

            type: "email",
            message: "请输入正确的邮箱地址",
            trigger: ["blur", "change"]
          }
        ],
        phonenumber: [
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "请输入正确的手机号码",
            trigger: "blur"
          }
        ]
      },
      //上传form
      upload: {
        title: "",
        open: false,
        //是不是在js里面调用接口，所以调接口加了BASE_API和token
        url: process.env.VUE_APP_BASE_API + "/system/user/importData",
        //是否更新已经存在的用户数据
        updateSupport: 0,
        //是否禁用上传
        isUploading: false,
        //设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() }
      }
    };
  },
  methods: {
    //点部门时触发查询
    handleNodeClick(data) {
      this.queryParams.deptId = data.id
      this.handleQuery();
    },
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    //重置
    resetQuery() {
      this.dateRange = [];
      // queryForm ref引用，resetForm 全局方法
      this.resetForm("queryForm");
      this.handleQuery();
    },
    getDeptTree() {
      deptTreeSelect().then(response => {
        this.depts = response.data;
      })
    },
    //重置表单
    reset() {
      this.form = {
        userId: undefined,
        deptId: undefined,
        userName: undefined,
        nickName: undefined,
        password: undefined,
        phonenumber: undefined,
        email: undefined,
        status: undefined,
        remark: undefined,
        sex: undefined,
        postIds: [],
        roleIds: []
      };
      this.resetForm("form");
    },
    //添加用户，add layout打开
    handlerAdd() {
      this.reset();
      this.open = true;
      this.title = "添加用户";
      /* 这里设置了密码，页面也显示了，不输入的时候还是提示密码不存在
      * created加了初始化密码后，rules不报错了, 密码必须是字符串，输入整数的时候有rules提示 = =！！！*/
      this.form.password = this.initPassword;
      // 部门和角色列表在created 的时候就加载了
      getPosts().then(response => {
        this.posts = response.rows
      })

    },
    //设置用户状态
    //this.$modal是vue.js中的插件，用于创建和管理模态框
    handlerStatusChange(row) {
      let text = row.status === "0" ? "启用" : "停用"
      this.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗？"').then(() => {
        return changeUserStatus(row.userId, row.status);
      }).then(() => {
        this.$modal.msgSuccess(text + "成功");
      }).catch(function () {
        row.status = row.status === "0" ? 1 : 0;
      })
    },
    //更新用户时查询单个用户
    handleUpdate(row) {
      this.reset();
      this.open = true;
      this.title = "修改用户";
      //this.ids 和新增在一起的修改没有row输入参数，所以用this.ids
      //handleSelectionChange 多选触发，保存ids 
      const userId = row.userId || this.ids;
      getUserById(userId).then(response => {
        this.form = response.data
        this.form.password = "";
        //因为角色roles在created的时候获取了，所以不用这样，岗位没有获取，所以需要获取岗位列表，通常情况下，一个用户详情接口不会返岗位列表，只会返id
        this.posts = response.posts;
        //response.postIds 0: 2,用户属于哪个部门，
        // response.roleIds 0: 2用户署遇哪个角色
        this.$set(this.form, "postIds", response.postIds);
        this.$set(this.form, "roleIds", response.roleIds)
      });
    },
    //删除
    handlerDelete(row) {
      const userIds = row.userId || this.ids;
      this.$modal.confirm("确认要删除用户").then(() => {
        return deleteUser(userIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { })
    },
    /** 查询用户列表 */
    getList() {
      this.loading = true
      // addDateRange 添加日期范围 全局挂载方法
      getUsers(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
        this.users = response.rows;
        this.total = response.total;
        this.loading = false;
      })
    },
    // 筛选节点,模糊查询部门节点
    filterNode(value, data) {
      if (!value) {
        return true;
      }
      return data.label.indexOf(value) !== -1;
    },
    // 多选框选中数据
    /**data里面定义了single,multiple,一开始没有多选，新增旁边的修改和删除按钮是禁用的
     * 后面多选了，值变为false，不禁用了
     * */
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.userId);
      //修改按钮
      this.single = selection.length != 1;
      //multiple 删除按钮
      this.multiple = !selection.length;
    },
    //数据导出
    handleExport() {
      /**为啥会有三个点.扩展运算符 用于对象：将一个对象的所有属性展开到一个新对象中
       *  this.download('system/user/export',{...this.queryParams}, `user_${new Date().getTime()}.xlsx`)
       * 我直接传一个对象进去也可以根据条件导出
       * 
      */
      this.download('system/user/export', this.queryParams, `user_${new Date().getTime()}.xlsx`)
    },
    //数据导入
    handleImport() {
      this.upload.title = "用户导入";
      this.upload.open = true;
    },
    //上传文件进度
    handleFileUploadProgress(response, file, fileList) {
      this.upload.isUploading = true;
    },
    //提交文件
    submitFileForm() {
      /**ref引用，如果不用ref引用，能不能提交？
       * 
       * this.upload.submit(); this.upload.submit is not a function
      */
      this.$refs.upload.submit();
      //this.upload.submit();
    },
    //上传文件成功
    handleFileSuccess(response, file, fileList) {

      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    //导入模板
    importTemplate() {
      this.download('system/user/importTemplate', {}, `user_template_${new Date().getTime()}.xlsx`);
    },
    //添加用户
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.userId != undefined) {
            updateUser(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
            });
          } else {
            addUser(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
            });
          }
          this.open = false;
          this.getList();
        }
      })
    },
    //添加用户取消
    cancel() {
      this.open = false;
      this.getList();
    },
    //更多
    handleCommand(command, row) {
      switch (command) {
        case "handleResetPwd":
          this.handleResetPwd(row);
          break;
        case "handleAuthRole":
          this.handleAuthRole(row);
          break;
        case "handleAuthDept":
          this.handleAuthDept(row);
          break;
        default:
          break;
      }
    },
    /** 重置密码按钮操作 */
    handleResetPwd: function (row) {
      this.$prompt('请输入“' + row.userName + '"的新密码', "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        closeOnClickModal: false,
        inputErrorMessage: "用户密码长度必须5-10之间"
      }).then(({ value }) => {
        resetUserPwd(row.userId, value).then(response => {
          this.$modal.msgSuccess("修改成功，新密码是：" + value);
        });
      })
    },
    /** 分配角色操作
     *  路由跳转/wu/role/my-role/role/ ,在router.js中配置了/wu/role/my-role 
     * 这个路由，最后一个/role匹配path里面的子路由
     * 
     */
    handleAuthRole: function (row) {
      const userId = row.userId;
      this.$router.push("/wu/role/my-role/role/" + userId);
    },
    handleAuthDept: function (row) {
      let userId = row.userId;
      this.$router.push("/wu/dept/user-dept/dept/" + userId);
    }
  },
  created() {
    //获取角色列表
    getRoles().then(response => {
      this.roles = response.rows
    });
    //获取部门列表
    this.getDeptTree();
    //获取用户列表
    this.getList();
    //this.getConfigKey("sys.user.initPassword").then(response => {
    //  this.initPassword = response.msg;
    //})
  }
}
</script>

<style>
</style>